package com.fwtai.controller.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.service.web.OrderWechatService;
import com.fwtai.tool.ToolClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 微信支付订单控制层|路由层
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @创建日期 2022-06-15 16:58:14
 * @官网 <url>http://www.fwtai.com</url>
*/
@RestController
@RequestMapping("/orderWechat")
public class OrderWechatController{

  private final OrderWechatService orderwechatService;

  public OrderWechatController(final OrderWechatService orderwechatService){
    this.orderwechatService = orderwechatService;
  }

  /**根据id查询对应的数据*/
  @PreAuthorize("hasAuthority('orderWechat_row_queryById')")
  @GetMapping("/queryById")
  public void queryById(final Long id,final HttpServletResponse response){
    ToolClient.responseJson(orderwechatService.queryById(id),response);
  }

  /**获取数据*/
  @PreAuthorize("hasAuthority('orderWechat_btn_listData')")
  @GetMapping("/listData")
  public void listData(final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(orderwechatService.listData(new PageFormData(request)),response);
  }
}